// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
// ------------------------------------------------------------------
// Modification history:
// feature: Code style modification
// ------------------------------------------------------------------

#ifndef SRC_CPP_UTILS_COLLECTIONS_IMPL_NODE_SIZES_CONFIG_HPP_
#define SRC_CPP_UTILS_COLLECTIONS_IMPL_NODE_SIZES_CONFIG_HPP_

// Only set defaults when not forced by the user
#if !defined(USE_STD_NODE_SIZES) && !defined(USE_FOONATHAN_NODE_SIZES) && !defined(USE_CUSTOM_NODE_SIZES)

// User can also set node types directly (both should be defined)
#if defined(STD_TREE_NODE_TYPE) || defined(STD_LIST_NODE_TYPE)
#if !defined(STD_TREE_NODE_TYPE) || !defined(STD_LIST_NODE_TYPE)
#error "Both STD_TREE_NODE_TYPE and STD_LIST_NODE_TYPE should be defined, but only one of them found"
#else
#define USE_STD_NODE_SIZES
#endif  // STD types check
// Select foonathan node size calculation when available
#elif !defined(FOONATHAN_MEMORY_NO_NODE_SIZE)
#define USE_FOONATHAN_NODE_SIZES
// Use custom solution as last resource
#else
#define USE_CUSTOM_NODE_SIZES
#endif  // Defaults selection

#else

// Check only one option has been selected
#if (defined(USE_FOONATHAN_NODE_SIZES) && defined(USE_STD_NODE_SIZES)) ||    \
    (defined(USE_FOONATHAN_NODE_SIZES) && defined(USE_CUSTOM_NODE_SIZES)) || \
    (defined(USE_CUSTOM_NODE_SIZES) && defined(USE_STD_NODE_SIZES))
#error "USE_STD_NODE_SIZES, USE_FOONATHAN_NODE_SIZES and USE_CUSTOM_NODE_SIZES are mutually exclusive"
// Check foonathan is available when selected
#elif defined(USE_FOONATHAN_NODE_SIZES) && defined(FOONATHAN_MEMORY_NO_NODE_SIZE)
#error "USE_FOONATHAN_NODE_SIZES selected but not available"
// Check std option is correctly configured
#elif defined(USE_STD_NODE_SIZES) && (!defined(STD_TREE_NODE_TYPE) || !defined(STD_LIST_NODE_TYPE))
#error "When USE_STD_NODE_SIZES is defined, STD_TREE_NODE_TYPE and STD_LIST_NODE_TYPE should be defined"
#endif  // Misconfiguration checks

#endif  // Options check

#endif /* SRC_CPP_UTILS_COLLECTIONS_IMPL_NODE_SIZES_CONFIG_HPP_ */
